package com.shujia.spark.core

import org.apache.spark.{SparkConf, SparkContext}

object Demo15Reduce {
  def main(args: Array[String]): Unit = {

    val conf = new SparkConf().setMaster("local").setAppName("Demo13Count")
    val sc = new SparkContext(conf)

    val rdd1 = sc.parallelize(List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))

    /**
      * reduce  对全表进行聚合    触发job执行
      *
      */
    val sum: Int = rdd1.reduce((x, y) => x + y)

    println(sum)

  }
}
